{% load humanize %}

<div id="comments">
    <div class="comments-header">
        <div class="comments-label">
            Comments ({{ comments|length }})
        </div>
        {% if user.is_authenticated %} 
            <div class="comments-add-link">
                <a href="javascript:showNewComment();">Post a Comment</a>
            </div>
        {% else %}
            <div class="comments-add-link">
                <a href="/accounts/login/?next=/map/sidebar/location/8975/">Sign in to Post comments</a>
            </div>
        {% endif %}
    </div>
    {% if user.is_authenticated %} 
        <div class="comment-new">
            <form action="/map/sidebar/location/discussion/new/{{ location_id }}/" method="post" target="sidebar-worker">
                <textarea name="comment" cols="20" rows="5"></textarea>
                <input type="submit" />
            </form>
        </div>
    {% endif %}
    {% if comments %}
        {% for comment in comments %}
            <div class="comment">
                <div class="comment-header">
                    <a class="comment-user" href="/profile/users/{{ user.username }}">{{ comment.user.username }}</a>
                     ({{ comment.posted|naturalday }}) 
                </div>
                <div class="comment-body">
                    {{ comment.comment }}
                </div>
            </div>
        {% endfor %}
    {% else %}
        <p>
            There are no comments yet.
        </p>
    {% endif %}
</div>
    